home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / DeveloperLabs / Lab3 / Solution / TextView.m < prev   
Text File  |  1995-06-12  |  2KB  |  76 lines

  1. /*
  2. **  TextView.m, implementation of scrolling text stuff for TextLab.
  3. **  Copyright 1989 NeXT, Inc.  All Rights Reserved.
  4. **  Author: Bruce Blumberg, NeXT Developer Support Group
  5. */
  6.  
  7.  
  8. #import <appkit/appkit.h>
  9. #import "TextView.h"
  10.  
  11. @implementation TextView:ScrollView
  12.  
  13. +newFrame:(const NXRect *)tFrame
  14. {    NXRect rect={0.0,0.0,0.0,0.0};
  15.     
  16.     /* create view */
  17.     self = [super newFrame:tFrame];
  18.     
  19.     /* specify scrollbars */
  20.         [[self setVertScrollerRequired:YES] setHorizScrollerRequired:NO];
  21.  
  22.         [self getContentSize:&(rect.size)];
  23.     theText = [self newText:&rect];
  24.     [self setDocView:theText];
  25.     
  26.     // The following two lines allow the resizing of the scrollview
  27.     // to be passed down to the docView (in this case, the text view 
  28.     // itself).
  29.  
  30.     [contentView setAutoresizeSubviews:YES];
  31.      [contentView setAutosizing:NX_HEIGHTSIZABLE | NX_WIDTHSIZABLE];
  32.  
  33.      // Create enclosing window, display it and bring it upfront
  34.     [self makeEnclosingWindow:tFrame];
  35.     [window setTitle:"Untitled"];
  36.     [window display];
  37.     [window makeKeyAndOrderFront:self];
  38.     [theText setSel:0:0];        
  39.     return(self);
  40. }
  41.  
  42. -makeEnclosingWindow:(const NXRect *)r
  43. {
  44.     id tWin;
  45.     
  46.     tWin = [Window newContent:r style:NX_TITLEDSTYLE 
  47.         backing:NX_BUFFERED buttonMask:NX_ALLBUTTONS defer:NO];
  48.     [tWin setContentView:self];
  49.     [tWin setBackgroundGray:NX_WHITE];
  50.     [tWin setFreeWhenClosed:YES];
  51.     return self;
  52. }
  53.     
  54. -newText:(const NXRect *)tF
  55. {
  56.     id text = [Text newFrame:tF text:NULL alignment:NX_LEFTALIGNED];
  57.     [text setOpaque:YES];
  58.     [[[[[text notifyAncestorWhenFrameChanged:YES]
  59.         setVertResizable:YES]
  60.         setHorizResizable:NO]
  61.         setMonoFont:NO]
  62.         setDelegate:self];
  63.     
  64.     { NXSize aSize = {1.0E38,1.0E38};
  65.       [text setMinSize:&tF->size];
  66.       [text setMaxSize:&aSize];
  67.         }
  68.     [text setCharFilter:NXEditorFilter];
  69.     return text;
  70. }
  71.  
  72. @end
  73.     
  74.  
  75.  
  76.